package com.atguigu.PracticalProject.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class AtguiguUtil {

    public static String toDate(Long ts) {
        return new SimpleDateFormat("yyyy-MM-dd").format(ts);
    }

    public static <T>List<T> toList(Iterable<T> it) {
        List<T> list = new ArrayList<>();
        it.forEach(new Consumer<T>() {
            @Override
            public void accept(T t) {
                list.add(t);
            }
        });
        return list;
    }

    public static String toDateTime(Long ts) {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(ts);
    }

    public static boolean isLarger(String one, String two) {
        //2022-08-20 06:23:01.933Z
        // 把z干掉, 然后直接比字符串
        one = one.replaceAll("Z", "");
        two = two.replaceAll("Z", "");
        // compareTo: one 大于tow的时候返回时正的
        return  one.compareTo(two) > 0;
    }

    public static boolean isLarger(String one, String two) {
        //2022-08-20 06:23:01.933Z
        // 把z干掉, 然后直接比字符串
        one = one.replaceAll("Z", "");
        two = two.replaceAll("Z", "");
        // compareTo: one 大于tow的时候返回时正的
        return  one.compareTo(two) > 0;
    }
}
